import { httpPost, httpGet, httpPut, httpDelete } from '@/services/request';
type int = number;
type List<T> = Array<T>;
type Collection<T> = Array<T>;

type JsonNode = any;
type long = number;
export interface TokenEntity {
  expireAt?: string;
  permissionCodeList?: string[];
  refreshExpireAt?: string;
  refreshToken?: string;
  refreshTokenFlag?: boolean;
  tenantPermissionCodeMap?: any;
  token?: string;
  userId?: string;
}

export interface AuthorizerGrantResult {
  authorId?: string;
  authorName?: string;
  authorType?: string;
  channelAuthor?: ChannelAuthor;
  channelId?: string;
  openId?: string;
  refreshToken?: string;
  token?: string;
  unionId?: string;
}

export interface ChannelAuthor {
  avatar?: string;
  gender?: number;
  info?: ObjectNode;
  nickName?: string;
  phone?: string;
}

export interface ObjectNode {
  array?: boolean;
  bigDecimal?: boolean;
  bigInteger?: boolean;
  binary?: boolean;
  boolean?: boolean;
  containerNode?: boolean;
  double?: boolean;
  float?: boolean;
  floatingPointNumber?: boolean;
  int?: boolean;
  integralNumber?: boolean;
  long?: boolean;
  missingNode?: boolean;
  nodeType?: string;
  null?: boolean;
  number?: boolean;
  object?: boolean;
  pojo?: boolean;
  short?: boolean;
  textual?: boolean;
  valueNode?: boolean;
}

export interface AuthorizerGrantInput {
  authCode?: string;
}

export interface WxMiniAuthorizerGrantInput {
  authCode?: string;
  encryptedData?: string;
  iv?: string;
}

export interface ManagerLoginAuthVO {
  loginName?: string;
  name?: string;
  permissionCodeList?: string[];
  roles?: string[];
  tenantId?: string;
  tenantPermissionCodeMap?: any;
  tenantRoleMap?: any;
  token?: string;
  userId?: string;
}

export interface ManagerLoginVO {
  loginName?: string;
  password?: string;
  validateCode?: string;
}

export interface NoticeCenter {
  /** 地点 */
  address?: string;
  /** 创建时间 */
  createDate?: string;
  /** 创建人ID */
  createUserId?: string;
  /** 删除标记 */
  delFlag?: number;
  /** 时长 */
  duration?: number;
  /** 结束时间 */
  endTime?: string;
  /** 图片Url地址 */
  imgUrl?: string;
  /** 分布式唯一ID */
  kid?: string;
  /** 最后修改时间 */
  lastUpdateDate?: string;
  /** 最后修改人ID */
  lastUpdateUserId?: string;
  /** 活动名称 */
  name?: string;
  /** 播放模式 0:无 1:独播 2:插播 */
  playMode?: number;
  /** 活动说明 */
  remark?: string;
  /** 资源类型 0活动 1视频 */
  resourceType?: number;
  /** 上下架标识 0上架 1下架 */
  shelveFlag?: number;
  /** 排序 */
  sort?: number;
  /** 间隔轮次 */
  spacing?: number;
  /** 主办方 */
  sponsor?: string;
  /** 开始时间 */
  startTime?: string;
  /** 活动类型 0无 1分享 2培训 3娱乐 4活动 5会议 6其他 */
  type?: number;
  /** 视频Url地址 */
  videoUrl?: string;
}

export interface PageList<T> {
  /** 数据总条数，前端接口可忽略改字段 */
  count?: string;
  /** 数据集合 */
  entities?: T[];
  /** 当前页码 */
  pageNo?: number;
  /** 每页条数 */
  pageSize?: number;
}

export interface SlideImageCheckTrail {
  attachId?: string;
  deviceType?: string;
  path?: string;
  serviceName?: string;
  trailPoints?: TrailPoint[];
}

export interface TrailPoint {
  direct?: number;
  relativeX?: number;
  relativeY?: number;
  speed?: number;
  timestamp?: string;
}

export interface SlideCheckImage {
  absCutAt?: AbsolutePosition;
  absInitAt?: AbsolutePosition;
  attachId?: string;
  cutUrl?: string;
  format?: string;
  imageHeight?: number;
  imageWidth?: number;
  orgUrl?: string;
  redrawUrl?: string;
  relativeCutAt?: RelativePosition;
  relativeInitAt?: RelativePosition;
}

export interface AbsolutePosition {
  h?: number;
  w?: number;
  x?: number;
  y?: number;
}

export interface RelativePosition {
  x?: number;
  y?: number;
}

export interface SlideImageCheckInit {
  path?: string;
  serviceName?: string;
}

export interface UpgradeInfoVO {
  /** 认证类型 */
  appId?: string;
  /** 0不用清理缓存 1需清理缓存 */
  clearCacheFlag?: number;
  /** 0数据无新版本 1数据有新版本 */
  dataUpgradeFlag?: number;
  /** 设备类型1苹果 2安卓 */
  devType?: number;
  /** 下载地址 */
  downloadUrl?: string;
  /** 0非强制升级 1强制升级 */
  forceUpgradeFlag?: number;
  /** 0不用退出登录 1退出登录 */
  logoutFlag?: number;
  /** 新版本号 */
  newAppVersion?: string;
  /** 数据新版本号 */
  newDataVersion?: number;
  /** 0无新版本 1有新版本 */
  upgradeFlag?: number;
  /** 升级提醒信息 */
  upgradeNotice?: string;
}

export interface VerifyCode {
  /** 业务类型由接入方自定义,例如:1.注册、2 .登录、3.找回密码、4注册/登录、5其他等、6找回支付密码 */
  serviceCode?: number;
  /** 验证码，校验时传入 */
  verifyCode?: string;
  /** 发送验证码类型 10默认 40缘卡小程序 */
  verifyCodeType?: number;
  /** 发送目标手机号 */
  verifyKey?: string;
  /** 发送类型 0-手机号/1-邮箱 */
  verifyType?: string;
}

export interface WxTemplate {
  /** 模版内容 */
  content?: string;
  /** 模板内容示例 */
  example?: string;
  /** 模板 id */
  priTmplId?: string;
  /** 模版标题 */
  title?: string;
  /** 模版类型，2 为一次性订阅，3 为长期订阅 */
  type?: number;
}

export interface ImageCheckRequest {
  /** 图片URL地址 */
  imgUrl?: string;
}

export interface TextCheckRequest {
  /** 文字内容 */
  content?: string;
}

export interface ExcelExportRecord {
  /** 创建时间 */
  createDate?: string;
  /** 创建人ID */
  createUserId?: string;
  /** 导出码 */
  exportCode?: string;
  /** 导出描述 */
  exportDesc?: string;
  /** 导出参数 */
  exportParams?: string;
  /** 导出状态：0未执行 1导出中 2全部导出 3部分导出 4导出失败 */
  exportStatus?: number;
  /** 分布式唯一ID */
  kid?: string;
  /** 最后修改时间 */
  lastUpdateDate?: string;
  /** 最后修改人ID */
  lastUpdateUserId?: string;
  /** 结果excel文件地址 */
  resultExcel?: string;
}

export interface ListRequest<T> {
  /** 数据集合 */
  dataList?: T[];
  /** 请求类型 */
  type?: T;
}

export interface PushMessage {
  /** 应用ID */
  appId?: string;
  /** 创建时间 */
  createDate?: string;
  /** 创建人ID */
  createUserId?: string;
  /** 删除标识 */
  delFlag?: number;
  /** 分布式唯一ID */
  kid?: string;
  /** 最后修改时间 */
  lastUpdateDate?: string;
  /** 最后修改人ID */
  lastUpdateUserId?: string;
  /** 消息推送时间 */
  messageDate?: string;
  /** 消息ID */
  messageId?: string;
  /** 消息类型，客户端根据此类型做消息展示归类 */
  messageType?: string;
  /** 极光任务ID */
  pushJobId?: string;
  /** 资源数据 */
  resource?: string;
  /** 资源类型 */
  resourceType?: string;
}

export interface SensitiveWordVO {
  /** 替换字符，默认* */
  replaceWord?: string;
  /** 原始文本内容 */
  text?: string;
}

export interface UploadSignResult {
  /** AccessKeyId */
  accessId?: string;
  /** 当前服务器时间（毫秒） */
  currentTime?: string;
  /** 失效时间（毫秒） */
  expireAt?: string;
  /** Bucket的host地址 */
  host?: string;
  /** Policy表单域 */
  policy?: string;
  /** 签名信息 */
  signature?: string;
}

export interface VideoCheckLog {
  /** 鉴黄检查结果，序列化成json串存储 */
  aiPornResponse?: string;
  /** 腾讯云检查返回的结果，序列化成json串存储 */
  checkResponse?: string;
  /** 处理状态 0-待检查 1-检查成功 2-检查失败 */
  checkStatus?: number;
  /** 创建时间 */
  createDate?: string;
  /** 创建人ID */
  createUserId?: string;
  /** 文件ID */
  fileId?: string;
  /** 视频文件的URL地址 */
  fileUrl?: string;
  /** 分布式唯一ID */
  kid?: string;
  /** 最后修改时间 */
  lastUpdateDate?: string;
  /** 最后修改人ID */
  lastUpdateUserId?: string;
  /** 鉴黄结果发送到MQ的exchange */
  mqExchange?: string;
  /** 鉴黄结果发送到MQ的routingKey */
  mqRoutingKey?: string;
  /** 腾讯云上的唯一请求 ID */
  requestId?: string;
  /** 任务编号 */
  taskId?: string;
}
export default {
  managerAccounts: {
    /**
     * 管理后台获取token缓存信息
     */
    getToken(): Promise<TokenEntity> {
      return httpPost(
        `/platform-support/v1.0/manager-accounts/action/get-token`
      ).then((res: any) => res.data.data);
    },
    /**
     * 管理后台登录
     */
    login(loginVO: ManagerLoginVO): Promise<ManagerLoginAuthVO> {
      return httpPost(
        `/platform-support/v1.0/pb/manager-accounts/action/login`,
        loginVO
      ).then((res: any) => res.data.data);
    }
  },
  authorizerGrant: {
    /**
     * 支付宝公众号授权
     */
    aliWeb(
      authorizerGrantInput: AuthorizerGrantInput
    ): Promise<AuthorizerGrantResult> {
      return httpPost(
        `/platform-support/v1.0/pb/authorizer-grant/action/ali-web`,
        authorizerGrantInput
      ).then((res: any) => res.data.data);
    },
    /**
     * 钉钉扫码授权
     */
    dingTalk(
      authorizerGrantInput: AuthorizerGrantInput
    ): Promise<AuthorizerGrantResult> {
      return httpPost(
        `/platform-support/v1.0/pb/authorizer-grant/action/dingTalk`,
        authorizerGrantInput
      ).then((res: any) => res.data.data);
    },
    /**
     * 微信小程序授权
     */
    wxMini(
      wxMiniAuthorizerGrantInput: WxMiniAuthorizerGrantInput
    ): Promise<AuthorizerGrantResult> {
      return httpPost(
        `/platform-support/v1.0/pb/authorizer-grant/action/wx-mini`,
        wxMiniAuthorizerGrantInput
      ).then((res: any) => res.data.data);
    },
    /**
     * 微信公众号授权
     */
    wxWeb(
      authorizerGrantInput: AuthorizerGrantInput
    ): Promise<AuthorizerGrantResult> {
      return httpPost(
        `/platform-support/v1.0/pb/authorizer-grant/action/wx-web`,
        authorizerGrantInput
      ).then((res: any) => res.data.data);
    }
  },
  healths: {
    /**
     * 健康检查
     */
    check(): Promise<boolean> {
      return httpGet(`/platform-support/v1.0/pb/healths/action/check`).then(
        (res: any) => res.data.data
      );
    }
  },
  liveChatLogs: {
    /**
     * 网易云历史消息回调
     */
    sendMsgLog(requestBody: string): Promise<boolean> {
      return httpPost(
        `/platform-support/v1.0/pb/live-chat-logs/action/sendMsgLog`,
        requestBody
      ).then((res: any) => res.data.data);
    }
  },
  noticeCenters: {
    /**
     * APP查询分页NoticeCenter
     */
    list(params: {
      pageNo?: number;
      pageSize?: number;
    }): Promise<PageList<NoticeCenter>> {
      return httpGet(`/platform-support/v1.0/pb/notice-centers/action/list`, {
        ...params
      }).then((res: any) => res.data.data);
    }
  },
  slideImages: {
    /**
     * 验证
     */
    doCheck(body: SlideImageCheckTrail): Promise<string> {
      return httpPost(
        `/platform-support/v1.0/pb/slide-images/action/doCheck`,
        body
      ).then((res: any) => res.data.data);
    },
    /**
     * 查询刷新
     */
    doQueryRefresh(body: SlideImageCheckInit): Promise<SlideCheckImage> {
      return httpPost(
        `/platform-support/v1.0/pb/slide-images/action/doQueryRefresh`,
        body
      ).then((res: any) => res.data.data);
    }
  },
  upgrades: {
    /**
     * APP更新升级查询
     */
    check(params: { dataVersion?: string }): Promise<UpgradeInfoVO> {
      return httpGet(`/platform-support/v1.0/pb/upgrades/action/check`, {
        ...params
      }).then((res: any) => res.data.data);
    }
  },
  verify: {
    /**
     * 验证(手机)验证码
     */
    check(codeDTO: VerifyCode): Promise<number> {
      return httpPost(
        `/platform-support/v1.0/pb/verify/action/check`,
        codeDTO
      ).then((res: any) => res.data.data);
    },
    /**
     * 获取(手机)验证码
     */
    getCode(params: {
      serviceCode?: number;
      verifyCode?: string;
      verifyCodeType?: number;
      verifyKey?: string;
      verifyType?: string;
    }): Promise<number> {
      return httpGet(`/platform-support/v1.0/pb/verify/action/getCode`, {
        ...params
      }).then((res: any) => res.data.data);
    },
    /**
     * 获取(手机)验证码
     */
    getCodeWithSlide(params: {
      serviceCode?: number;
      verifyCode?: string;
      verifyCodeType?: number;
      verifyKey?: string;
      verifyType?: string;
    }): Promise<number> {
      return httpGet(
        `/platform-support/v1.0/pb/verify/action/getCodeWithSlide`,
        { ...params }
      ).then((res: any) => res.data.data);
    }
  },
  getTemplateList: {
    /**
     * 获取微信消息模板列表
     */
    get(): Promise<List<WxTemplate>> {
      return httpGet(`/platform-support/v1.0/pb/wxPush/get-template-list`).then(
        (res: any) => res.data.data
      );
    }
  },
  QQCheckLogs: {
    /**
     * 图片安全检查 0:图片合法，1：图片非法，2：检查失败
     */
    imgCheck(request: ImageCheckRequest): Promise<number> {
      return httpPost(
        `/platform-support/v1.0/pt/QQ-check-logs/action/img-check`,
        request
      ).then((res: any) => res.data.data);
    },
    /**
     * 文字安全检查 0:文字合法，1：文字非法，2：检查失败
     */
    textCheck(request: TextCheckRequest): Promise<number> {
      return httpPost(
        `/platform-support/v1.0/pt/QQ-check-logs/action/text-check`,
        request
      ).then((res: any) => res.data.data);
    }
  },
  doCertification: {
    /**
     * 实名认证
     */
    get(params: { idCard: string; name: string }): Promise<number> {
      return httpGet(
        `/platform-support/v1.0/pt/certification/doCertification`,
        { ...params }
      ).then((res: any) => res.data.data);
    }
  },
  config: {
    /**
     * 获取CDN签名密钥配置信息（加密后的）
     */
    encryptCdnsignSecret(): Promise<string> {
      return httpGet(
        `/platform-support/v1.0/pt/config/action/encrypt-cdnsign-secret`
      ).then((res: any) => res.data.data);
    },
    /**
     * 获取CDN签名密钥配置信息
     */
    getCdnsignSecret(): Promise<string> {
      return httpGet(
        `/platform-support/v1.0/pt/config/action/get-cdnsign-secret`
      ).then((res: any) => res.data.data);
    }
  },
  excelExports: {
    /**
     * 合作方导出数据
     */
    export(excelExportRecord: ExcelExportRecord): Promise<boolean> {
      return httpPost(
        `/platform-support/v1.0/pt/excel-exports/action/export`,
        excelExportRecord
      ).then((res: any) => res.data.data);
    }
  },
  pushMessages: {
    /**
     * APP端删除消息
     */
    batchDelete(listRequest: ListRequest<string>): Promise<number> {
      return httpPut(
        `/platform-support/v1.0/pt/push-messages/action/batch-delete`,
        listRequest
      ).then((res: any) => res.data.data);
    },
    /**
     * APP端查询分页数据
     */
    listPage(params: {
      messageType: string;
      pageNo?: number;
      pageSize?: number;
    }): Promise<PageList<PushMessage>> {
      return httpGet(
        `/platform-support/v1.0/pt/push-messages/action/list-page`,
        { ...params }
      ).then((res: any) => res.data.data);
    }
  },
  sensitiveWords: {
    /**
     * 校验文本中是否包含敏感词
     */
    check(sensitiveWordVO: SensitiveWordVO): Promise<boolean> {
      return httpPost(
        `/platform-support/v1.0/pt/sensitive-words/action/check`,
        sensitiveWordVO
      ).then((res: any) => res.data.data);
    },
    /**
     * 检查并返回文本中的敏感词
     */
    match(sensitiveWordVO: SensitiveWordVO): Promise<Set<string>> {
      return httpPost(
        `/platform-support/v1.0/pt/sensitive-words/action/match`,
        sensitiveWordVO
      ).then((res: any) => res.data.data);
    },
    /**
     * 替换文本中的敏感词并返回
     */
    replace(sensitiveWordVO: SensitiveWordVO): Promise<string> {
      return httpPost(
        `/platform-support/v1.0/pt/sensitive-words/action/replace`,
        sensitiveWordVO
      ).then((res: any) => res.data.data);
    }
  },
  uploads: {
    /**
     * 获取OSS上传签名参数(加密)
     */
    securitySign(params: { permission?: string }): Promise<UploadSignResult> {
      return httpGet(`/platform-support/v1.0/pt/uploads/action/security-sign`, {
        ...params
      }).then((res: any) => res.data.data);
    },
    /**
     * 获取OSS上传签名参数
     */
    sign(params: { permission?: string }): Promise<UploadSignResult> {
      return httpGet(`/platform-support/v1.0/pt/uploads/action/sign`, {
        ...params
      }).then((res: any) => res.data.data);
    }
  },
  videoCheckLogs: {
    /**
     * APP端查询分页数据
     */
    listPage(params: {
      pageNo?: number;
      pageSize?: number;
    }): Promise<PageList<VideoCheckLog>> {
      return httpGet(
        `/platform-support/v1.0/pt/video-check-logs/action/list-page`,
        { ...params }
      ).then((res: any) => res.data.data);
    }
  }
};
